package com.ruoyi.common.utils.easyExcel;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;

import java.util.List;

public class EasyExcelListenerFactory<T> {

    List<T> list;

    public EasyExcelListenerFactory(List<T> list) {
        this.list = list;
    }

    public AnalysisEventListener getListener(){
        return new ListenerBuilder();
    }

    class ListenerBuilder extends AnalysisEventListener<T>{

        @Override
        public void invoke(T t, AnalysisContext analysisContext) {
            list.add(t);
        }

        @Override
        public void doAfterAllAnalysed(AnalysisContext analysisContext) {

        }

    }


}
